package com.southwind.service;

import com.alibaba.fastjson.JSONObject;
import com.southwind.entity.Menu;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Service;

@Service
@RocketMQMessageListener(consumerGroup = "menuMQConsumer",topic = "menuTopic")
@Slf4j
public class messageConsumerService implements RocketMQListener<Menu> {

    @Override
    public void onMessage(Menu menu) {

        System.out.println("开始消费");

//        try {
//            Thread.sleep(5000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }

        System.out.println("菜单： " + menu);
        String menuString = JSONObject.toJSONString(menu,true);
        System.out.println("菜单String： " + menuString);

    }
}
